require File.join(File.dirname(__FILE__), 'http_server')

require 'sequel/postgres'
DB = Sequel('postgres://postgres:postgres@localhost:5432/reality_development')
NODES = DB[:nodes]

HTTP::Template.set(:node_inspect, '<p><%= @node.inspect %></p>')

server = HTTP::Server.new do
  include HTTP::Static
  
  def handle
    # @node = NODES[:path => @uri]
    # send_representation(HTTP::STATUS_OK, 'text/html', HTTP::Template.render(:node_inspect, binding))

    serve_static(File.dirname(__FILE__) / @uri)
  end
end

trap("INT") do
  exit
end
puts "Serving on port 8081..."
server.start("0.0.0.0", 8081)

